#include "threadpool.hpp"
#include "Task.hpp"

int main()
{
  //ThreadPool<Task> *tp = new ThreadPool<Task>;
  //tp->Start();
  ThreadPool<Task> *tp = ThreadPool<Task>::GetInstance();
  tp->Start();
  srand(time(nullptr) ^ getpid());
  while (1)
  {
    // 构建任务
    int x = rand() % 10 + 1;
    usleep(10);
    int y = rand() % 5;
    char op = opers[rand() % opers.size()];
    Task t(x, y, op);

    // 交给线程池处理
    tp->Push(t);
    cout << "main thread make task: " << t.GetTask() << endl;
    sleep(1);
  }
  return 0;
}